From fd2197646d46e4c4040e0f1c88c18ad63c3fe439 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 29 Nov 2016 22:45:56 +0100 Subject: [PATCH] babl-cache: factor out construction of header line --- babl/babl-cache.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/babl/babl-cache.c b/babl/babl-cache.c index 1f0b6f5..818c126 100644 --- a/babl/babl-cache.c +++ b/babl/babl-cache.c @@ -135,6 +135,14 @@ static int compare_fish_pixels (const void *a, const void *b) ((*fb)->fish.processings - (*fa)->fish.processings); } +static const char *cache_header (void) +{ + static char buf[2048]; + sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f", + BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ()); + return buf; +} + void babl_store_db (void) { BablDb *db = babl_fish_db (); @@ -142,8 +150,7 @@ void babl_store_db (void) FILE *dbfile = fopen (fish_cache_path (), "w"); if (!dbfile) return; - fprintf (dbfile, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f\n", - BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ()); + fprintf (dbfile, "%s\n", cache_header ()); /* sort the list of fishes by usage, making next run more efficient - * and the data easier to approach as data for targeted optimization @@ -254,10 +261,7 @@ void babl_init_db (void) case '#': /* if babl has changed in git .. drop whole cache */ { - char buf[2048]; - sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f", - BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ()); - if (strcmp ( token, buf)) + if (strcmp ( token, cache_header ())) { free (contents); return; -- 2.30.2